﻿using DataAccess;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace UI
{
    public partial class frmCasingString : Form
    {
        private DataTable initDt;
        private DataTable dispDt;
        public frmCasingString()
        {
            InitializeComponent();
            InitializeGridView();
            InitGridControlData();
        }

        private void InitializeGridView()
        {
            gridView1.OptionsView.ShowGroupPanel = false;
            gridView1.OptionsBehavior.Editable = false;
            gridView1.IndicatorWidth = 35;
        }

        private void InitGridControlData()
        {

            initDt = AccessHelper.commSearch("casing_string");
            initDt.Columns[1].ColumnName = "井号";
            initDt.Columns[2].ColumnName = "套管程序";
            initDt.Columns[3].ColumnName = "套管串结构";

            dispDt = new DataTable();
            dispDt.Columns.Add(new DataColumn("井号", typeof(string)));
            dispDt.Columns.Add(new DataColumn("套管程序", typeof(string)));
            dispDt.Columns.Add(new DataColumn("套管串结构", typeof(string)));
           
            DataRow dr = null;
            foreach (DataRow row in initDt.Rows)
            {
                dr = dispDt.NewRow();
                dr["井号"] = row["井号"];
                dr["套管程序"] = row["套管程序"];
                dr["套管串结构"] = row["套管串结构"];
                dispDt.Rows.Add(dr);
            }

            gridControl1.DataSource = dispDt;
        }

        private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            if (e.Info.IsRowIndicator && e.RowHandle >= 0)
                e.Info.DisplayText = (e.RowHandle + 1).ToString();
        }

    }
}
